import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: () => import('@/views/layout/index.vue'),
      children: [
        {
          path: '',
          component: () => import('@/views/home/home.vue'),
        },
        {
          path: 'category/:id',
          component: () => import('@/views/category/category.vue'),
        },
        {
          path: 'category/sub/:id',
          component: () => import('@/views/subCategory/index.vue'),
        },
        {
          path: `detail/:id`,
          component: () => import('@/views/detail/index.vue'),
        },
        {
          path: 'cartList',
          component: () => import('@/views/cart/cart.vue'),
        },
        {
          path: 'checkOut',
          component: () => import('@/views/checkout/checkOut.vue'),
        },
        {
          path: 'pay',
          component: () => import('@/views/pay/index.vue'),
        },
        {
          path: 'search',
          component: () => import('@/views/search/index.vue'),
        },
        {
          path: 'member',
          component: () => import('@/views/user/index.vue'),
          children: [
            {
              path: 'user',
              component: () => import('@/views/user/user/userInfo.vue'),
            },
            {
              path: 'order',
              component: () => import('@/views/user/user/userOrder.vue'),
            },
          ],
        },
      ],
    },
    {
      path: '/login',
      component: () => import('@/views/login/login.vue'),
    },
    {
      path: '/sku',
      component: () => import('@/views/detail/index.vue'),
    },
  ],
  scrollBehavior: () => ({ top: 0 }),
})

export default router
